/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CashSimulator.java
 *
 * Created on Apr 24, 2011, 7:31:03 PM
 */
package POS_Source;

import POS_Controller.POSController;
import java.text.DecimalFormat;

/**
 * this class renders the simulated view of payment by cash
 * @author Spence
 * @see POS_Source
 */
public class CashSimulator extends javax.swing.JPanel {

    private double amountInserted;
    private POSController controller;
    private DecimalFormat formatter;

    /** Creates new form CashSimulator */
    public CashSimulator(POSController control) {
        initComponents();
        controller = control;
        formatter = new DecimalFormat("0.00");
//        MoneyDueLabel.setText("$" + formatter.format(moneyDue));
//        MoneyPaidLabel.setText("$" +formatter.format(amountInserted));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ButtonPanel = new javax.swing.JPanel();
        fiveDollarButton = new javax.swing.JButton();
        tenDollarButton = new javax.swing.JButton();
        twentyDollarButton = new javax.swing.JButton();
        fiftyDollarButton = new javax.swing.JButton();
        hundredDollarButton = new javax.swing.JButton();
        fiveCentsButton = new javax.swing.JButton();
        tenCentsButton = new javax.swing.JButton();
        twentyfiveCentsButton = new javax.swing.JButton();
        dollarButton = new javax.swing.JButton();
        twoDollarButton = new javax.swing.JButton();
        PayCardButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        DuePanel = new javax.swing.JPanel();
        MoneyDueLabel = new javax.swing.JLabel();
        DueLabel = new javax.swing.JLabel();
        PaidPanel = new javax.swing.JPanel();
        MoneyPaidLabel = new javax.swing.JLabel();
        PaidLabel = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        ButtonPanel.setBackground(new java.awt.Color(255, 255, 255));

        fiveDollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        fiveDollarButton.setText("$5.00");
        fiveDollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fiveDollarButtonActionPerformed(evt);
            }
        });

        tenDollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        tenDollarButton.setText("$10.00");
        tenDollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tenDollarButtonActionPerformed(evt);
            }
        });

        twentyDollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        twentyDollarButton.setText("$20.00");
        twentyDollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                twentyDollarButtonActionPerformed(evt);
            }
        });

        fiftyDollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        fiftyDollarButton.setText("$50.00");
        fiftyDollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fiftyDollarButtonActionPerformed(evt);
            }
        });

        hundredDollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        hundredDollarButton.setText("$100.00");
        hundredDollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hundredDollarButtonActionPerformed(evt);
            }
        });

        fiveCentsButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        fiveCentsButton.setText("$0.05");
        fiveCentsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fiveCentsButtonActionPerformed(evt);
            }
        });

        tenCentsButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        tenCentsButton.setText("$0.10");
        tenCentsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tenCentsButtonActionPerformed(evt);
            }
        });

        twentyfiveCentsButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        twentyfiveCentsButton.setText("$0.25");
        twentyfiveCentsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                twentyfiveCentsButtonActionPerformed(evt);
            }
        });

        dollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        dollarButton.setText("$1.00");
        dollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dollarButtonActionPerformed(evt);
            }
        });

        twoDollarButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        twoDollarButton.setText("$2.00");
        twoDollarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                twoDollarButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout ButtonPanelLayout = new org.jdesktop.layout.GroupLayout(ButtonPanel);
        ButtonPanel.setLayout(ButtonPanelLayout);
        ButtonPanelLayout.setHorizontalGroup(
            ButtonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(ButtonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(ButtonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(tenCentsButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(twoDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(dollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(fiveCentsButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(twentyfiveCentsButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(ButtonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(tenDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(hundredDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(fiftyDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(fiveDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(twentyDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 168, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        ButtonPanelLayout.setVerticalGroup(
            ButtonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(ButtonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(ButtonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(ButtonPanelLayout.createSequentialGroup()
                        .add(fiveCentsButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(6, 6, 6)
                        .add(tenCentsButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(twentyfiveCentsButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(dollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(twoDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(ButtonPanelLayout.createSequentialGroup()
                        .add(fiveDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(6, 6, 6)
                        .add(tenDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(twentyDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(fiftyDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(hundredDollarButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        PayCardButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        PayCardButton.setText("Pay Rest By Card");
        PayCardButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PayCardButtonActionPerformed(evt);
            }
        });

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        DuePanel.setBackground(new java.awt.Color(255, 255, 255));

        MoneyDueLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 24)); // NOI18N

        DueLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 24)); // NOI18N
        DueLabel.setText("Amount Due");

        org.jdesktop.layout.GroupLayout DuePanelLayout = new org.jdesktop.layout.GroupLayout(DuePanel);
        DuePanel.setLayout(DuePanelLayout);
        DuePanelLayout.setHorizontalGroup(
            DuePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(DuePanelLayout.createSequentialGroup()
                .add(DuePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, DuePanelLayout.createSequentialGroup()
                        .addContainerGap(29, Short.MAX_VALUE)
                        .add(DueLabel))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, DuePanelLayout.createSequentialGroup()
                        .add(29, 29, 29)
                        .add(MoneyDueLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)))
                .addContainerGap())
        );
        DuePanelLayout.setVerticalGroup(
            DuePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(DuePanelLayout.createSequentialGroup()
                .add(DueLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(MoneyDueLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
        );

        PaidPanel.setBackground(new java.awt.Color(255, 255, 255));

        MoneyPaidLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 24)); // NOI18N

        PaidLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 24)); // NOI18N
        PaidLabel.setText("Amount Paid");

        org.jdesktop.layout.GroupLayout PaidPanelLayout = new org.jdesktop.layout.GroupLayout(PaidPanel);
        PaidPanel.setLayout(PaidPanelLayout);
        PaidPanelLayout.setHorizontalGroup(
            PaidPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(PaidPanelLayout.createSequentialGroup()
                .add(PaidPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, MoneyPaidLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, PaidLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(49, Short.MAX_VALUE))
        );
        PaidPanelLayout.setVerticalGroup(
            PaidPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(PaidPanelLayout.createSequentialGroup()
                .add(PaidLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(MoneyPaidLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(PaidPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 49, Short.MAX_VALUE)
                .add(DuePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(PaidPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(DuePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel7.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 60)); // NOI18N
        jLabel7.setText("Cash Simulation");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(232, 232, 232)
                        .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(295, 295, 295)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, PayCardButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, ButtonPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 573, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(275, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(30, 30, 30)
                .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ButtonPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(PayCardButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 66, Short.MAX_VALUE)
                .add(jLabel7)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    /**
     *
     * @param evt
     */
    private void dollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dollarButtonActionPerformed
        addAmount(1);
    }//GEN-LAST:event_dollarButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void twoDollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_twoDollarButtonActionPerformed
        addAmount(2);
    }//GEN-LAST:event_twoDollarButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void hundredDollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hundredDollarButtonActionPerformed
        addAmount(100);
    }//GEN-LAST:event_hundredDollarButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void fiftyDollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fiftyDollarButtonActionPerformed
        addAmount(50);
    }//GEN-LAST:event_fiftyDollarButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void fiveCentsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fiveCentsButtonActionPerformed
        addAmount(0.05);
    }//GEN-LAST:event_fiveCentsButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void tenCentsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tenCentsButtonActionPerformed
        addAmount(0.1);
    }//GEN-LAST:event_tenCentsButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void twentyfiveCentsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_twentyfiveCentsButtonActionPerformed
        addAmount(0.25);
    }//GEN-LAST:event_twentyfiveCentsButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void fiveDollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fiveDollarButtonActionPerformed
        addAmount(5);
    }//GEN-LAST:event_fiveDollarButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void tenDollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tenDollarButtonActionPerformed
        addAmount(10);
    }//GEN-LAST:event_tenDollarButtonActionPerformed
/**
 * this method handles button press event
 * @param evt
 */
    private void twentyDollarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_twentyDollarButtonActionPerformed
        addAmount(25);
    }//GEN-LAST:event_twentyDollarButtonActionPerformed
/**
 * this method handles pay by cash button event by redirecting the request to controller
 * @param evt
 */
    private void PayCardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PayCardButtonActionPerformed

        controller.makeCashPayment(amountInserted);
    }//GEN-LAST:event_PayCardButtonActionPerformed

    /**
     * this method implements add amount action
     * @param amount
     */
    private void addAmount(double amount) {
        amountInserted += amount;

        MoneyPaidLabel.setText("$" + formatter.format(amountInserted));
        double moneyDue = controller.getSessionManager().totalDue() - amountInserted;
        moneyDue = roundDouble(moneyDue);
        System.out.println("money due is " + moneyDue);
        MoneyDueLabel.setText("$" + formatter.format(moneyDue));

        if (moneyDue <= 0) {
            controller.makeCashPayment(amountInserted + moneyDue);
            System.out.println("Need to give the customer $" + moneyDue * -1);
            MoneyDueLabel.setText("$" + formatter.format(amountInserted + moneyDue));
            MoneyPaidLabel.setText("$" + formatter.format(amountInserted));
        }

    }
/**
 * this method rounds up the double value 
 * @param num
 * @return a double value
 */
    private double roundDouble(double num) {
        String temp = formatter.format(num);
        double newDbl = Double.parseDouble(temp);
        return newDbl;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ButtonPanel;
    private javax.swing.JLabel DueLabel;
    private javax.swing.JPanel DuePanel;
    private javax.swing.JLabel MoneyDueLabel;
    private javax.swing.JLabel MoneyPaidLabel;
    private javax.swing.JLabel PaidLabel;
    private javax.swing.JPanel PaidPanel;
    private javax.swing.JButton PayCardButton;
    private javax.swing.JButton dollarButton;
    private javax.swing.JButton fiftyDollarButton;
    private javax.swing.JButton fiveCentsButton;
    private javax.swing.JButton fiveDollarButton;
    private javax.swing.JButton hundredDollarButton;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JButton tenCentsButton;
    private javax.swing.JButton tenDollarButton;
    private javax.swing.JButton twentyDollarButton;
    private javax.swing.JButton twentyfiveCentsButton;
    private javax.swing.JButton twoDollarButton;
    // End of variables declaration//GEN-END:variables
}
